home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13532 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  917 b 

  1. Path: ccshst05.cs.uoguelph.ca!ccshst01!thay
  2. From: thay@uoguelph.ca (Toby K Hay)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: accessing structures via pointers
  5. Date: 8 Apr 1996 15:58:22 GMT
  6. Organization: University of Guelph
  7. Message-ID: <4kbd2u$rp6@ccshst05.cs.uoguelph.ca>
  8. References: <1996Apr8.144012.25767@leeds.ac.uk>
  9. NNTP-Posting-Host: ccshst01.cs.uoguelph.ca
  10. X-Newsreader: TIN [version 1.2 PL2]
  11.  
  12. A M Casey (csyamc@scs.leeds.ac.uk) wrote (roughly, with a lot excised):
  13. : Hi I'm calling the function getgrent(), which returns a pointer to the 
  14. structure: 
  15. : struct group *getgrent(void);
  16. : and I havent got a clue how to access it.
  17. : printf("the group name is %s\n",tempgroup.gr_name);
  18. : doesnt work because tempgroup is a pointer.
  19.  
  20. To access structure elements through structure pointers you have to use 
  21. "->" instead of ".".  That is, "tempgroup->gr_name" instead of 
  22. "tempgroup.gr_name".  
  23. Toby Hay    thay@uoguelph.ca
  24.